﻿using Aierp.Utility.Data;
using System.Collections.Generic;

namespace Aierp.Repository
{
    public interface IRepository<T>
    {
        /// <summary>
        /// 获取数据列表
        /// </summary>
        /// <param name="filter"></param>
        /// <param name="sortOrder"></param>
        /// <param name="limit"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        string GetList(int limit, int offset, string filter, string sortOrder);

        /// <summary>
        ///  查询单个实体-根据关键字
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        T Find(string key);

        /// <summary>
        ///  查询单个实体-根据ID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T FindById(int id);

        /// <summary>
        /// 获取所有实体
        /// </summary>
        /// <returns></returns>
        List<T> FindAll();

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        int Add(T item);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        int Remove(int key);

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        int Update(T item);
    }
}
